#!/bin/bash
# 使用expect输入密码登录


ip="101.11.11.11"
pass="xxx"

expect -c "
    spawn ssh -i ~/xueleixin.pem xueleixin@$ip
    expect {
        \"passphrase\" {set timeout 6000; send \"$pass\n\"; exp_continue ; sleep 3; }
        \"yes/no\" {send \"yes\n\"; exp_continue;}
        \"Last*\" {  send_user \"\n成功登录\n\";}
    }
   
interact"